﻿@using GitCandy.Web.Extensions
@model GitCandy.Models.BlameModel

@{
    ViewBag.Title = String.Format(SR.Shared_TitleFormat, String.Format(SR.Repository_BlameTitle, Model.Name, Model.ReferenceName ?? Model.Sha.ToShortSha(), Model.Path));
}

<h4>
    @await Html.PartialAsync("_RepositoryLink", Model)
</h4>

@await Html.PartialAsync("_PathBar", Model.PathBar)
@await Html.PartialAsync("_BranchSelector", Model.BranchSelector)

<div class="row">
    <div class="col-md-12">
        <div class="pull-right">
            @Html.ActionLink(SR.Repository_History, "Commits", new { path = (Model.ReferenceName ?? Model.Sha) + "/" + Model.Path }, new { @class = "btn btn-default" })
            @Html.ActionLink(SR.Repository_NormalView, "Blob", new { path = (Model.ReferenceName ?? Model.Sha) + "/" + Model.Path }, new { @class = "btn btn-default" })
            @Html.ActionLink(SR.Repository_Raw, "Raw", new { path = (Model.ReferenceName ?? Model.Sha) + "/" + Model.Path }, new { @class = "btn btn-default" })
        </div>
        @Model.SizeString
    </div>
</div>

<table class="table table-bordered" data-brush="@Model.Brush">
    <tbody>
        @foreach (var hunk in Model.Hunks)
        {
            <tr>
                <td class="blame-info">
                    <div>
                        <span>@Html.ActionLink(hunk.Sha.ToShortSha(), "Commit", new { path = hunk.Sha + "/" + Model.Path })</span>
                        <span>@Html.ActionLink("»", "Blame", new { path = hunk.Sha + "/" + Model.Path })</span>
                        <strong title="@hunk.AuthorEmail">@hunk.Author</strong>
                    </div>
                    <div>
                        <span title="@hunk.AuthorDate">@hunk.AuthorDate.LocalDateTime.ToFullString()</span>
                        <span title="@hunk.MessageShort">@hunk.MessageShort.ShortString(33)</span>
                    </div>
                </td>
                <td><pre class="blame-code"><code class="language no-highlight blame-code">@hunk.Code</code></pre></td>
            </tr>
        }
    </tbody>
</table>
